

--全局数据
Global = {
    windows = {},
}

require 'fairygui.FairyGUI'
require 'fairygui.UnityEngine'

require("luakit")
require("lstdfs")
require("luabus")
require("ltimer")
require("lsmdb")
require("luapb")
require("ljson")
require("lssl")

require 'base.base'

require ("core.TimeMgr")
require ("core.MsgMgr")
require ("core.LanMgr")
require ("core.StoreMgr")
require ("core.KeCodeMgr")
require ("core.WorldMgr")
require ("core.LogMgr")

function Update()
    local curTime = os.time()
    g_lan_mgr:update(curTime)
    g_msg_mgr:update(curTime)
    g_time_mgr:update(curTime)
    g_keycode_mgr:update(curTime)
    timer.sleep(1)
end

local opfile = _G.OpenFile
print("main gage start: ", opfile)

UIPackage.AddPackage("FairyGUI/Basic");

CS.FairyGUI.UIConfig.tooltipsWin = "ui://nk9ejx23fj4c6y"
CS.FairyGUI.UIConfig.popupMenu  = "ui://nk9ejx23dqzd8i"

local tex = CS.UnityEngine.Resources.Load("Cursor/cursor_finger")
Stage.inst:RegisterCursor("text-link", tex, CS.UnityEngine.Vector2(0,0))

CS.UnityEngine.Screen.SetResolution(1200, 800, false)
GRoot.inst:SetContentScaleFactor(1200, 800, CS.FairyGUI.UIContentScaler.ScreenMatchMode.MatchWidth)

if opfile and opfile:find(".db") then
    _G.OpenFile = stdfs.absolute(opfile)
    local main_ui = Fairy_Create_GUI("MainUI")
    main_ui:open()
else
    _G.OpenFile = nil
    local start_ui = Fairy_Create_GUI("StartUI")
    start_ui:open()
end
